{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 测试成功"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "100"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%matplotlib qt5\n",
    "from PIL import Image\n",
    "import matplotlib.pyplot as plt\n",
    "im = Image.new(\"I\", (512, 512), 1000)\n",
    "draw = ImageDraw.Draw(im,mode='I')\n",
    "draw.rectangle((100, 200, 300, 400), 100, 100)\n",
    "fig,ax=plt.subplots()\n",
    "plt.imshow(im)\n",
    "plt.show()\n",
    "im.getpixel((150,283)) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "\n",
    "import numpy as np\n",
    "from PIL import Image\n",
    "from PIL import ImageDraw\n",
    "from PIL import ImageFont\n",
    " \n",
    " \n",
    "def draw_test():\n",
    " \n",
    "    #生成深蓝色绘图画布\n",
    "    array = np.ndarray((480, 640, 3), np.uint8)\n",
    " \n",
    "    array[:, :, 0] = 0\n",
    "    array[:, :, 1] = 0\n",
    "    array[:, :, 2] = 100\n",
    " \n",
    "    image = Image.fromarray(array)\n",
    " \n",
    "    #创建绘制对象\n",
    "    draw = ImageDraw.Draw(image,mode='L')\n",
    "    \n",
    "    #绘制直线\n",
    "    draw.line((20, 20, 150, 150), 'cyan')\n",
    " \n",
    "    #绘制矩形\n",
    "    draw.rectangle((100, 200, 300, 400), 'black', 'red')\n",
    " \n",
    "    #绘制弧\n",
    "    draw.arc((100, 200, 300, 400), 0, 180, 'yellow')\n",
    "    draw.arc((100, 200, 300, 400), -90, 0, 'green')\n",
    " \n",
    "    #绘制弦\n",
    "    draw.chord((350, 50, 500, 200), 0, 120, 'khaki', 'orange')\n",
    " \n",
    "    #绘制圆饼图\n",
    "    draw.pieslice((350, 50, 500, 200), -150, -30, 'pink', 'crimson')\n",
    "    \n",
    "    #绘制椭圆\n",
    "    draw.ellipse((350, 300, 500, 400), 'yellowgreen', 'wheat')\n",
    "    #外切矩形为正方形时椭圆即为圆\n",
    "    draw.ellipse((550, 50, 600, 100), 'seagreen', 'skyblue') \n",
    " \n",
    "    #绘制多边形\n",
    "    draw.polygon((150, 180, 200, 180, 250, 120, 230, 90, 130, 100), 'olive', 'hotpink')\n",
    " \n",
    "    #绘制文本\n",
    "    font = ImageFont.truetype(\"consola.ttf\", 40, encoding=\"unic\")#设置字体\n",
    "    draw.text((100, 50), u'Hello World', 'fuchsia', font)\n",
    " \n",
    "    image.show()\n",
    "    return\n",
    "draw_test()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
